//
//  RecommandViewController.m
//  X-Tribe
//
//  Created by my-pc on 16/4/2.
//  Copyright © 2016年 Miss.Ou. All rights reserved.
//

#import "RecommandViewController.h"
#import "RcomTableViewCell.h"
#import "TODetailViewController.h"
#import "TOActivityPicTableViewCell.h"

@interface RecommandViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,weak)UITableView *mytableView;
@end

@implementation RecommandViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor greenColor];
    
    //创建子控件
    [self setupTabView];
    
    
    
}

-(void)setupTabView
{
    UITableView *tableview = [[UITableView alloc]init];
    tableview.frame = self.view.bounds;
    tableview.delegate = self;
    tableview.dataSource = self;
    [self.view addSubview:tableview];

    //自定义cell Xib注册
    [tableview registerNib:[UINib nibWithNibName:@"RcomTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"RcomTableViewCell"];
    
    //自定义cell Xib注册
    [tableview registerNib:[UINib nibWithNibName:@"TOActivityPicTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"TOActivityPicTableViewCell"];
    self.mytableView = tableview;
    
    

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
    

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   static NSString *cellID = @"RcomTableViewCell";
    
    if(indexPath.row%2==0){
    RcomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    return cell;
    
    }else{
        TOActivityPicTableViewCell *picCell = [tableView dequeueReusableCellWithIdentifier:@"TOActivityPicTableViewCell"];
        
        return picCell;
    
    }

    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    if(indexPath.row%2==0){
        return 210;
    }else{
        return 250;
    }

}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    TODetailViewController *detailVC = [[TODetailViewController alloc] init];
    [self.navigationController pushViewController:detailVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
